package cn.liumouren.tool.security.core;

import java.util.*;

/**
 * {@link Permission}默认实现
 *
 * @author Daniel Liu
 * @date 2021/3/6 13:42
 */
public class DefaultPermission implements Permission {

    /**
     * 存放所有拥有的所有权限
     */
    private final List<String> permission = new ArrayList<>();

    @Override
    public List<String> get() {
        return permission;
    }

    @Override
    public void add(String... permissions) {
        addAll(Arrays.asList(permissions));
    }

    @Override
    public void addAll(Collection<String> permissions) {
        if (permissions != null && permissions.size() > 0) {
            Set<String> set = new HashSet<>(permissions);
            permission.addAll(set);
        }
    }
}
